<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ page import="com.onlineMIS.ORM.entity.headQ.finance.FinanceCategory"%>
<%@ page import="com.onlineMIS.common.Common_util"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><s:property value="formBean.order.typeS" /> <s:property
		value="财务详情" /></title>

</head>
<%@ include file="../../common/Style.jsp"%>
<script>
var dataGrid ;
$(document).ready(function(){
	$('#dlg').dialog('close');
	$("#financeCategoryType").combobox('setValue',<%=Common_util.ALL_RECORD%>);
	
	var params = $.serializeObject($('#SalesOrderSearchForm'));
	dataGrid = $('#dataGrid').datagrid({
  		url : 'financeHQJSON!searchFinanceDetails',
		queryParams: params,
		fit : true,
   		fitColumns : true,
   		border : false,
   		pagination : false,
		pageSize : 15,
		pageList : [ 15, 30],	
   		checkOnSelect : false,
   		selectOnCheck : false,
   		singleSelect:true,
   		showFooter:true,
   		rownumbers:true,
   		nowrap : false,
   		rowStyler: function(index,row){
			var style = "";
			if (row.flowName == "本日合计")
				style += 'color:red;';			
			return style;
		},
		columns : [[
				{field:'flowId',align:'center', width:30,title:'单据号',
					formatter: function (value, row, index){
						if(row.flowId === 0){
							return "";
						}else{
							return row.flowId;
						}						
					}},
				{field:'flowName', align:'center',width:140,title:'名称'},
				{field:'transferType',align:'center', width:40,title:'账目类型'},
				{field:'billDateS',align:'center', width:60,title:'单据时间'},
				{field:'total', align:'center',width:70,title:'金额',
					formatter: function (value, row, index){
						if(row.flowName == "本日合计"){
							return "";
						}else{
							return (row.total).toFixed(2);
						}						
					}},
				{field:'borrowerAmount', align:'center',width:70,title:'借方金额',
					formatter: function (value, row, index){
						return (row.borrowerAmount).toFixed(2);
					}},
				{field:'lenderAmount', align:'center',width:70,title:'贷方金额',
					formatter: function (value, row, index){
						return (row.lenderAmount).toFixed(2);
					}},
				{field:'balance',align:'center', width:70,title:'余额',
					formatter: function (value, row, index){
						if(row.flowName == "本日合计"){
							return "";
						}else{
							return (row.balance).toFixed(2);
						}						
					}},
				{field:'flowType', width:70,title:'账目归属',align: 'center',
					formatter :  function(value, row, index) {
						var str = "";
						if(row.flowId !=0){
							str = $.formatString('<button class="button3">'+row.flowType+'</button>');
						}										
					return str;
				}},
				{field:'comment', width:240,title:'备注'},
				{field:'flowBelong', width:140,title:'账目详情',
					formatter : function(value, row, index) {
						var str = '';
						if(row.flowBelong == <%=FinanceCategory.CATEGORY_TYPE_CUST%>){							
							var url = "financeHQJSP!getFHQ?formBean.financeBill.id=" + row.flowId;
							var nodeTitle = "客户财务单据"+ row.flowId;
							if (row.flowId != 0){							  					
								 str += $.formatString('<a href="javascript:addTab3(\'{0}\',\'{1}\');"><img border="0" src="{2}" title="详情"/></a>',url,nodeTitle,'<%=request.getContextPath()%>/conf_files/easyUI/themes/icons/update.png');							
							}
							return str;
						}else if(row.flowBelong == <%=FinanceCategory.CATEGORY_TYPE_SUPPLIER%>){
							var url = "financeSupplierJSP!getFHQ?formBean.order.id=" + row.flowId;
							var nodeTitle = "财务单据"+ row.flowId;
							if (row.flowId != 0){							  					
								 str += $.formatString('<a href="javascript:addTab3(\'{0}\',\'{1}\');"><img border="0" src="{2}" title="详情"/></a>',url,nodeTitle,'<%=request.getContextPath()%>/conf_files/easyUI/themes/icons/update.png');							
							}
							return str;
						}else if(row.flowBelong == <%=FinanceCategory.CATEGORY_TYPE_INSTITUTION%>){
							var str = '';     				
	        				str += $.formatString('<a href="#" onclick="viewDetails(\'{0}\');"><img border="0" src="{1}" /></a>', row.flowId,'<%=request.getContextPath()%>/conf_files/easyUI/themes/icons/update.png');        			       				
	        				return str;
						}else{
							var url = 'financeHQJSP!editExpense?formBean.expenseHq.id=' + row.flowId;
							if(row.flowId != 0){							
								str += $.formatString('<a href="#" onclick="addTab6(\'{0}\',\'{1}\');"><img border="0" src="{2}" title="编辑账目"/></a>',url,row.flowName + row.flowId,'<%=request.getContextPath()%>/conf_files/easyUI/themes/icons/update.png');						
							
							    return str;
							}
						}

					}
					
				},
				
			     ]],
		toolbar : '#toolbar',
	
	});
});

function searchAcctFlow(){	
	dataGrid.datagrid('load', $.serializeObject($('#SalesOrderSearchForm')));	
}


function downloadAcctFlow(){
	document.SalesOrderSearchForm.action="financeHQJSP!downloadAccountsFlow";
	document.SalesOrderSearchForm.submit();
}

/**
 * 查询机构转账详情
 */
function viewDetails(orderId){
	console.log(orderId);
	var params= "formBean.financeBillCorpFlow.id=" +orderId;
    $.post("action/financeHQJSON!selectFBCorpFlowById",params, searchBkProcess,"json");
}

function searchBkProcess(date){
	if(date !=  null){
		 $("#orderId").textbox('setValue', date.date.id);
		 $("#acctUser").textbox('setValue', date.date.accounting);
		 $("#into").textbox('setValue', date.date.toCategory);
		 $("#goOut").textbox('setValue', date.date.fromCategory);
		 $("#orderDate").textbox('setValue', date.date.date);
		 $("#orderCreateTime").textbox('setValue', date.date.createDate);
		 $("#amountMoney").textbox('setValue', date.date.amount);
		 $("#orderComment").textbox('setValue', date.date.comment);
	}
	$('#dlg').dialog('open');
	
}

</script>
<body>
	
	<div class="easyui-layout" data-options="fit : true,border : false">
	<div data-options="region:'north',border:false" style="height: 120px;">
	<s:form id="SalesOrderSearchForm" name="SalesOrderSearchForm"
		action=""
		theme="simple" method="POST">
		<input type="hidden" id="isAll" name="formBean.isAll" value="1" />
		<input type="hidden" id="indicator" name="formBean.indicator"
			value="0" />
		<table width="98%" align="center" class="OuterTable">
			<tr>
				<td>
					<table width="100%" border="0">
						<tr>
							<td height="50" colspan="7">
								<div class="errorAndmes">
									<s:actionerror cssStyle="color:red" />
									<s:actionmessage cssStyle="color:blue" />
								</div>
								<table width="100%" border="0">
									<tr class="PBAOuterTableTitale">
										<td height="51" colspan="3">账目管理 &nbsp-->  &nbsp <s:property value="formBean.fc.itemName"/>&nbsp-->&nbsp 流水详情<br />  
										</td>
										
									</tr>
									<tr  height="40">
										
										<td width="30%">单据日期：<s:textfield id="startDate"
											name="formBean.searchStartTime" cssClass="easyui-datebox"
											data-options="width:100,editable:false" /> &nbsp; 至&nbsp; <s:textfield
											id="endDate" name="formBean.searchEndTime"
											cssClass="easyui-datebox"
											data-options="width:100,editable:false" />
											<s:hidden name="formBean.fc.id"   />
											</td>	
										<td width="5%" align="center"><strong>账目类型: </strong></td>
										<td align="left">
												<s:select cssClass="easyui-combobox" style="width:140px" name="formBean.financeCategoryType" data-options="prompt:'请选择账目类型'"   id="financeCategoryType" listKey="key" listValue="value" headerKey="-1" headerValue="" list="#{'0':'客户账目','1':'供应商账目','2':'机构账目','3':'总部账目'}" ></s:select>														
										</td>											
									</tr>
								
								</table>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		</s:form>
	</div>
	
	<div id="dlg" class="easyui-dialog" title="转账记录明细" data-options="iconCls:'icon-tip'" style="width:400px;height:500px;padding:20px">
			<table class="OuterTable" width="100%" border="1">
				<tr>
					<td width="15%" height="30">单据号：</td>
				
					<td width="35%"><input class="easyui-textbox" id="orderId"  style="width:180px" ></td></tr>
					<tr>
					<td width="15%">转账人员：</td>
					<td><input class="easyui-textbox"  id="acctUser" style="width:180px" ></td></tr>

					<tr>
					<td width="15%" height="30">转入：</td>
					<td width="35%"><input class="easyui-textbox" id="into"  style="width:180px" ></td></tr>
					<tr>
					<td width="15%">转出</td>
					<td><input class="easyui-textbox" id="goOut"  style="width:180px" ></td></tr>

					<tr>
					<td width="15%" height="30">单据时间：</td>
					<td width="35%"><input class="easyui-textbox"  id="orderDate" style="width:180px" ></td></tr>
					<tr>
					<td width="15%">创建时间：</td>
					<td><input class="easyui-textbox" id="orderCreateTime"  style="width:180px" ></td></tr>

					<tr>
					<td width="15%" height="30">转账金额：</td>
					<td colspan="3"><input class="easyui-textbox" id="amountMoney"  style="width:180px" ></td></tr>
					
					<tr>
					<td height="30">备注信息：</td>
					<td colspan="3"><input class="easyui-textbox" id="orderComment"  style="width:180px" ></td>
				</tr>

			</table>
    </div>
	
			<div data-options="region:'center',border:false">
			<table id="dataGrid">
			</table>
			
			<div id="toolbar" style="display: none;">
				<a onclick="searchAcctFlow();" href="javascript:void(0);"
					class="easyui-linkbutton"
					data-options="iconCls:'icon-search',plain:true">查询账目</a> 
					<a onclick="downloadAcctFlow();" href="javascript:void(0);"
					class="easyui-linkbutton"
					data-options="iconCls:'icon-print',plain:true">下载账目</a> 

			</div>
		</div>
</div>
</body>
</html>